<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>迁徙图</title>
</head>
<body>
    <div id="map-wrapO" style="height: 920px;width: 49.9%;float: left">
        <!-- 这里以后是地图 -->
    </div>
    <div id="map-wrapD" style="height: 920px;width: 49.9%;float: right">
        <!-- 这里以后是地图 -->
    </div>
</body>
<script src="../../mapData/js/jquery.min.js"></script>
<script type="text/javascript" src="../../mapData/js/echarts/echarts.js"></script>
<script type="text/javascript">
    var geoCoordMap = {
        '长治县': [113.056679,36.052438],
        '屯留县': [112.892741,36.314072],
        '襄垣县': [113.050094,36.532854],
        '城区': [113.114107,36.187896],
        '平顺县': [113.438791,36.200202],
        '黎城县': [113.387366,36.502971],
        '壶关县': [113.206138,36.110938],
        '长子县': [112.884656,36.119484],
        '沁县': [112.70138,36.757123],
        '武乡县': [112.8653,36.834315],
        '沁源县': [112.340878,36.500777],
        '潞城市': [113.223245,36.332233],
        '郊区': [113.101211,36.218388]
    };
    // O分析数据
    var LCDataO = [
        [{name:'潞城市'}, {name:'长治县',value:95}],
        [{name:'潞城市'}, {name:'屯留县',value:90}],
        [{name:'潞城市'}, {name:'襄垣县',value:80}],
        [{name:'潞城市'}, {name:'城区',value:70}],
        [{name:'潞城市'}, {name:'平顺县',value:300}],
        [{name:'潞城市'}, {name:'黎城县',value:50}],
        [{name:'潞城市'}, {name:'壶关县',value:40}],
        [{name:'潞城市'}, {name:'长子县',value:30}],
        [{name:'潞城市'}, {name:'沁县',value:200}],
        [{name:'潞城市'}, {name:'武乡县',value:100}],
        [{name:'潞城市'}, {name:'沁源县',value:30}],
        [{name:'潞城市'}, {name:'郊区',value:20}]
    ];

    var PSXDataO = [
        [{name:'平顺县'}, {name:'长治县',value:95}],
        [{name:'平顺县'}, {name:'屯留县',value:90}],
        [{name:'平顺县'}, {name:'襄垣县',value:80}],
        [{name:'平顺县'}, {name:'城区',value:70}],
        [{name:'平顺县'}, {name:'潞城市',value:60}],
        [{name:'平顺县'}, {name:'黎城县',value:500}],
        [{name:'平顺县'}, {name:'壶关县',value:40}],
        [{name:'平顺县'}, {name:'长子县',value:30}],
        [{name:'平顺县'}, {name:'沁县',value:20}],
        [{name:'平顺县'}, {name:'武乡县',value:100}],
        [{name:'平顺县'}, {name:'沁源县',value:30}],
        [{name:'平顺县'}, {name:'郊区',value:20}]
    ];

    var JQDataO = [
        [{name:'郊区'}, {name:'长治县',value:95}],
        [{name:'郊区'}, {name:'屯留县',value:90}],
        [{name:'郊区'}, {name:'襄垣县',value:80}],
        [{name:'郊区'}, {name:'城区',value:70}],
        [{name:'郊区'}, {name:'平顺县',value:60}],
        [{name:'郊区'}, {name:'黎城县',value:50}],
        [{name:'郊区'}, {name:'壶关县',value:40}],
        [{name:'郊区'}, {name:'长子县',value:30}],
        [{name:'郊区'}, {name:'沁县',value:20}],
        [{name:'郊区'}, {name:'武乡县',value:10}],
        [{name:'郊区'}, {name:'沁源县',value:30}],
        [{name:'郊区'}, {name:'潞城市',value:20}]
    ];
    var CZXDataO = [
        [{name:'长治县'}, {name:'郊区',value:95}],
        [{name:'长治县'}, {name:'屯留县',value:90}],
        [{name:'长治县'}, {name:'襄垣县',value:80}],
        [{name:'长治县'}, {name:'城区',value:70}],
        [{name:'长治县'}, {name:'平顺县',value:60}],
        [{name:'长治县'}, {name:'黎城县',value:50}],
        [{name:'长治县'}, {name:'壶关县',value:40}],
        [{name:'长治县'}, {name:'长子县',value:30}],
        [{name:'长治县'}, {name:'沁县',value:20}],
        [{name:'长治县'}, {name:'武乡县',value:10}],
        [{name:'长治县'}, {name:'沁源县',value:30}],
        [{name:'长治县'}, {name:'潞城市',value:20}]
    ];
    var TLXDataO = [
        [{name:'屯留县'}, {name:'郊区',value:95}],
        [{name:'屯留县'}, {name:'长治县',value:90}],
        [{name:'屯留县'}, {name:'襄垣县',value:80}],
        [{name:'屯留县'}, {name:'城区',value:70}],
        [{name:'屯留县'}, {name:'平顺县',value:60}],
        [{name:'屯留县'}, {name:'黎城县',value:50}],
        [{name:'屯留县'}, {name:'壶关县',value:40}],
        [{name:'屯留县'}, {name:'长子县',value:30}],
        [{name:'屯留县'}, {name:'沁县',value:20}],
        [{name:'屯留县'}, {name:'武乡县',value:10}],
        [{name:'屯留县'}, {name:'沁源县',value:30}],
        [{name:'屯留县'}, {name:'潞城市',value:20}]
    ];
    var XHXDataO = [
        [{name:'襄垣县'}, {name:'郊区',value:95}],
        [{name:'襄垣县'}, {name:'长治县',value:90}],
        [{name:'襄垣县'}, {name:'屯留县',value:80}],
        [{name:'襄垣县'}, {name:'城区',value:70}],
        [{name:'襄垣县'}, {name:'平顺县',value:60}],
        [{name:'襄垣县'}, {name:'黎城县',value:50}],
        [{name:'襄垣县'}, {name:'壶关县',value:40}],
        [{name:'襄垣县'}, {name:'长子县',value:30}],
        [{name:'襄垣县'}, {name:'沁县',value:20}],
        [{name:'襄垣县'}, {name:'武乡县',value:10}],
        [{name:'襄垣县'}, {name:'沁源县',value:30}],
        [{name:'襄垣县'}, {name:'潞城市',value:20}]
    ];
    var CQDataO = [
        [{name:'城区'}, {name:'郊区',value:95}],
        [{name:'城区'}, {name:'长治县',value:90}],
        [{name:'城区'}, {name:'屯留县',value:80}],
        [{name:'城区'}, {name:'襄垣县',value:70}],
        [{name:'城区'}, {name:'平顺县',value:60}],
        [{name:'城区'}, {name:'黎城县',value:50}],
        [{name:'城区'}, {name:'壶关县',value:40}],
        [{name:'城区'}, {name:'长子县',value:30}],
        [{name:'城区'}, {name:'沁县',value:20}],
        [{name:'城区'}, {name:'武乡县',value:10}],
        [{name:'城区'}, {name:'沁源县',value:30}],
        [{name:'城区'}, {name:'潞城市',value:20}]
    ];
    var LCXDataO = [
        [{name:'黎城县'}, {name:'郊区',value:95}],
        [{name:'黎城县'}, {name:'长治县',value:90}],
        [{name:'黎城县'}, {name:'屯留县',value:80}],
        [{name:'黎城县'}, {name:'襄垣县',value:70}],
        [{name:'黎城县'}, {name:'平顺县',value:60}],
        [{name:'黎城县'}, {name:'城区',value:50}],
        [{name:'黎城县'}, {name:'壶关县',value:40}],
        [{name:'黎城县'}, {name:'长子县',value:30}],
        [{name:'黎城县'}, {name:'沁县',value:20}],
        [{name:'黎城县'}, {name:'武乡县',value:10}],
        [{name:'黎城县'}, {name:'沁源县',value:30}],
        [{name:'黎城县'}, {name:'潞城市',value:20}]
    ];
    var YGXDataO = [
        [{name:'壶关县'}, {name:'郊区',value:95}],
        [{name:'壶关县'}, {name:'长治县',value:90}],
        [{name:'壶关县'}, {name:'屯留县',value:80}],
        [{name:'壶关县'}, {name:'襄垣县',value:70}],
        [{name:'壶关县'}, {name:'平顺县',value:60}],
        [{name:'壶关县'}, {name:'城区',value:50}],
        [{name:'壶关县'}, {name:'黎城县',value:40}],
        [{name:'壶关县'}, {name:'长子县',value:30}],
        [{name:'壶关县'}, {name:'沁县',value:20}],
        [{name:'壶关县'}, {name:'武乡县',value:10}],
        [{name:'壶关县'}, {name:'沁源县',value:30}],
        [{name:'壶关县'}, {name:'潞城市',value:20}]
    ];
    var ZZXDataO = [
        [{name:'长子县'}, {name:'郊区',value:95}],
        [{name:'长子县'}, {name:'长治县',value:90}],
        [{name:'长子县'}, {name:'屯留县',value:80}],
        [{name:'长子县'}, {name:'襄垣县',value:70}],
        [{name:'长子县'}, {name:'平顺县',value:60}],
        [{name:'长子县'}, {name:'城区',value:50}],
        [{name:'长子县'}, {name:'黎城县',value:40}],
        [{name:'长子县'}, {name:'壶关县',value:30}],
        [{name:'长子县'}, {name:'沁县',value:20}],
        [{name:'长子县'}, {name:'武乡县',value:10}],
        [{name:'长子县'}, {name:'沁源县',value:30}],
        [{name:'长子县'}, {name:'潞城市',value:20}]
    ];
    var QXDataO = [
        [{name:'沁县'}, {name:'郊区',value:95}],
        [{name:'沁县'}, {name:'长治县',value:90}],
        [{name:'沁县'}, {name:'屯留县',value:80}],
        [{name:'沁县'}, {name:'襄垣县',value:70}],
        [{name:'沁县'}, {name:'平顺县',value:60}],
        [{name:'沁县'}, {name:'城区',value:50}],
        [{name:'沁县'}, {name:'黎城县',value:40}],
        [{name:'沁县'}, {name:'壶关县',value:30}],
        [{name:'沁县'}, {name:'长子县',value:20}],
        [{name:'沁县'}, {name:'武乡县',value:10}],
        [{name:'沁县'}, {name:'沁源县',value:30}],
        [{name:'沁县'}, {name:'潞城市',value:20}]
    ];
    var WXXDataO = [
        [{name:'武乡县'}, {name:'郊区',value:95}],
        [{name:'武乡县'}, {name:'长治县',value:90}],
        [{name:'武乡县'}, {name:'屯留县',value:80}],
        [{name:'武乡县'}, {name:'襄垣县',value:70}],
        [{name:'武乡县'}, {name:'平顺县',value:60}],
        [{name:'武乡县'}, {name:'城区',value:50}],
        [{name:'武乡县'}, {name:'黎城县',value:40}],
        [{name:'武乡县'}, {name:'壶关县',value:30}],
        [{name:'武乡县'}, {name:'长子县',value:20}],
        [{name:'武乡县'}, {name:'沁县',value:10}],
        [{name:'武乡县'}, {name:'沁源县',value:30}],
        [{name:'武乡县'}, {name:'潞城市',value:20}]
    ];
    var QYXDataO = [
        [{name:'沁源县'}, {name:'郊区',value:95}],
        [{name:'沁源县'}, {name:'长治县',value:90}],
        [{name:'沁源县'}, {name:'屯留县',value:80}],
        [{name:'沁源县'}, {name:'襄垣县',value:70}],
        [{name:'沁源县'}, {name:'平顺县',value:60}],
        [{name:'沁源县'}, {name:'城区',value:50}],
        [{name:'沁源县'}, {name:'黎城县',value:40}],
        [{name:'沁源县'}, {name:'壶关县',value:30}],
        [{name:'沁源县'}, {name:'长子县',value:20}],
        [{name:'沁源县'}, {name:'沁县',value:10}],
        [{name:'沁源县'}, {name:'武乡县',value:30}],
        [{name:'沁源县'}, {name:'潞城市',value:20}]
    ];
    // D分析数据
    var LCDataD = [
        [{name:'长治县',value:95},{name:'潞城市'}],
        [{name:'屯留县',value:90},{name:'潞城市'}],
        [{name:'襄垣县',value:80},{name:'潞城市'}],
        [{name:'城区',value:70},{name:'潞城市'}],
        [{name:'平顺县',value:60},{name:'潞城市'}],
        [{name:'黎城县',value:50},{name:'潞城市'}],
        [{name:'壶关县',value:40},{name:'潞城市'}],
        [{name:'长子县',value:30},{name:'潞城市'}],
        [{name:'沁县',value:20},{name:'潞城市'}],
        [{name:'武乡县',value:10},{name:'潞城市'}],
        [{name:'沁源县',value:30},{name:'潞城市'}],
        [{name:'郊区',value:20},{name:'潞城市'}]
    ];

    var PSXDataD = [
        [{name:'长治县',value:95},{name:'平顺县'}],
        [{name:'屯留县',value:90},{name:'平顺县'}],
        [{name:'襄垣县',value:80},{name:'平顺县'}],
        [{name:'城区',value:70},{name:'平顺县'}],
        [{name:'潞城市',value:60},{name:'平顺县'}],
        [{name:'黎城县',value:50},{name:'平顺县'}],
        [{name:'壶关县',value:40},{name:'平顺县'}],
        [{name:'长子县',value:30},{name:'平顺县'}],
        [{name:'沁县',value:20},{name:'平顺县'}],
        [{name:'武乡县',value:10},{name:'平顺县'}],
        [{name:'沁源县',value:30},{name:'平顺县'}],
        [{name:'郊区',value:20},{name:'平顺县'}]
    ];

    var JQDataD = [
        [{name:'长治县',value:95},{name:'郊区'}],
        [{name:'屯留县',value:90},{name:'郊区'}],
        [{name:'襄垣县',value:80},{name:'郊区'}],
        [{name:'城区',value:70},{name:'郊区'}],
        [{name:'平顺县',value:60},{name:'郊区'}],
        [{name:'黎城县',value:50},{name:'郊区'}],
        [{name:'壶关县',value:40},{name:'郊区'}],
        [{name:'长子县',value:30},{name:'郊区'}],
        [{name:'沁县',value:20},{name:'郊区'}],
        [{name:'武乡县',value:10},{name:'郊区'}],
        [{name:'沁源县',value:30},{name:'郊区'}],
        [{name:'潞城市',value:20},{name:'郊区'}]
    ];
    var CZXDataD = [
        [{name:'郊区',value:95},{name:'长治县'}],
        [{name:'屯留县',value:90},{name:'长治县'}],
        [{name:'襄垣县',value:80},{name:'长治县'}],
        [{name:'城区',value:70},{name:'长治县'}],
        [{name:'平顺县',value:60},{name:'长治县'}],
        [{name:'黎城县',value:50},{name:'长治县'}],
        [{name:'壶关县',value:40},{name:'长治县'}],
        [{name:'长子县',value:30},{name:'长治县'}],
        [{name:'沁县',value:20},{name:'长治县'}],
        [{name:'武乡县',value:10},{name:'长治县'}],
        [{name:'沁源县',value:30},{name:'长治县'}],
        [{name:'潞城市',value:20},{name:'长治县'}]
    ];
    var TLXDataD = [
        [{name:'郊区',value:95},{name:'屯留县'}],
        [{name:'长治县',value:90},{name:'屯留县'}],
        [{name:'襄垣县',value:300},{name:'屯留县'}],
        [{name:'城区',value:70},{name:'屯留县'}],
        [{name:'平顺县',value:60},{name:'屯留县'}],
        [{name:'黎城县',value:50},{name:'屯留县'}],
        [{name:'壶关县',value:40},{name:'屯留县'}],
        [{name:'长子县',value:30},{name:'屯留县'}],
        [{name:'沁县',value:20},{name:'屯留县'}],
        [{name:'武乡县',value:10},{name:'屯留县'}],
        [{name:'沁源县',value:300},{name:'屯留县'}],
        [{name:'潞城市',value:20},{name:'屯留县'}]
    ];
    var XHXDataD = [
        [{name:'郊区',value:95},{name:'襄垣县'}],
        [{name:'长治县',value:90},{name:'襄垣县'}],
        [{name:'屯留县',value:80},{name:'襄垣县'}],
        [{name:'城区',value:70},{name:'襄垣县'}],
        [{name:'平顺县',value:60},{name:'襄垣县'}],
        [{name:'黎城县',value:50},{name:'襄垣县'}],
        [{name:'壶关县',value:40},{name:'襄垣县'}],
        [{name:'长子县',value:30},{name:'襄垣县'}],
        [{name:'沁县',value:20},{name:'襄垣县'}],
        [{name:'武乡县',value:10},{name:'襄垣县'}],
        [{name:'沁源县',value:30},{name:'襄垣县'}],
        [{name:'潞城市',value:20},{name:'襄垣县'}]
    ];
    var CQDataD = [
        [{name:'郊区',value:95},{name:'城区'}],
        [{name:'长治县',value:90},{name:'城区'}],
        [{name:'屯留县',value:80},{name:'城区'}],
        [{name:'襄垣县',value:500},{name:'城区'}],
        [{name:'平顺县',value:60},{name:'城区'}],
        [{name:'黎城县',value:50},{name:'城区'}],
        [{name:'壶关县',value:40},{name:'城区'}],
        [{name:'长子县',value:30},{name:'城区'}],
        [{name:'沁县',value:20},{name:'城区'}],
        [{name:'武乡县',value:10},{name:'城区'}],
        [{name:'沁源县',value:30},{name:'城区'}],
        [{name:'潞城市',value:20},{name:'城区'}]
    ];
    var LCXDataD = [
        [{name:'郊区',value:95},{name:'黎城县'}],
        [{name:'长治县',value:90},{name:'黎城县'}],
        [{name:'屯留县',value:80},{name:'黎城县'}],
        [{name:'襄垣县',value:70},{name:'黎城县'}],
        [{name:'平顺县',value:60},{name:'黎城县'}],
        [{name:'城区',value:50},{name:'黎城县'}],
        [{name:'壶关县',value:40},{name:'黎城县'}],
        [{name:'长子县',value:30},{name:'黎城县'}],
        [{name:'沁县',value:20},{name:'黎城县'}],
        [{name:'武乡县',value:10},{name:'黎城县'}],
        [{name:'沁源县',value:30},{name:'黎城县'}],
        [{name:'潞城市',value:20},{name:'黎城县'}]
    ];
    var YGXDataD = [
        [{name:'郊区',value:95},{name:'壶关县'}],
        [{name:'长治县',value:90},{name:'壶关县'}],
        [{name:'屯留县',value:80},{name:'壶关县'}],
        [{name:'襄垣县',value:70},{name:'壶关县'}],
        [{name:'平顺县',value:60},{name:'壶关县'}],
        [{name:'城区',value:50},{name:'壶关县'}],
        [{name:'黎城县',value:40},{name:'壶关县'}],
        [{name:'长子县',value:30},{name:'壶关县'}],
        [{name:'沁县',value:20},{name:'壶关县'}],
        [{name:'武乡县',value:10},{name:'壶关县'}],
        [{name:'沁源县',value:30},{name:'壶关县'}],
        [{name:'潞城市',value:20},{name:'壶关县'}]
    ];
    var ZZXDataD = [
        [{name:'郊区',value:95},{name:'长子县'}],
        [{name:'长治县',value:90},{name:'长子县'}],
        [{name:'屯留县',value:80},{name:'长子县'}],
        [{name:'襄垣县',value:70},{name:'长子县'}],
        [{name:'平顺县',value:60},{name:'长子县'}],
        [{name:'城区',value:50},{name:'长子县'}],
        [{name:'黎城县',value:40},{name:'长子县'}],
        [{name:'壶关县',value:30},{name:'长子县'}],
        [{name:'沁县',value:20},{name:'长子县'}],
        [{name:'武乡县',value:10},{name:'长子县'}],
        [{name:'沁源县',value:30},{name:'长子县'}],
        [{name:'潞城市',value:20},{name:'长子县'}]
    ];
    var QXDataD = [
        [{name:'郊区',value:95},{name:'沁县'}],
        [{name:'长治县',value:200},{name:'沁县'}],
        [{name:'屯留县',value:80},{name:'沁县'}],
        [{name:'襄垣县',value:70},{name:'沁县'}],
        [{name:'平顺县',value:60},{name:'沁县'}],
        [{name:'城区',value:50},{name:'沁县'}],
        [{name:'黎城县',value:40},{name:'沁县'}],
        [{name:'壶关县',value:300},{name:'沁县'}],
        [{name:'长子县',value:20},{name:'沁县'}],
        [{name:'武乡县',value:10},{name:'沁县'}],
        [{name:'沁源县',value:30},{name:'沁县'}],
        [{name:'潞城市',value:20},{name:'沁县'}]
    ];
    var WXXDataD = [
        [{name:'郊区',value:95},{name:'武乡县'}],
        [{name:'长治县',value:90},{name:'武乡县'}],
        [{name:'屯留县',value:80},{name:'武乡县'}],
        [{name:'襄垣县',value:70},{name:'武乡县'}],
        [{name:'平顺县',value:60},{name:'武乡县'}],
        [{name:'城区',value:50},{name:'武乡县'}],
        [{name:'黎城县',value:40},{name:'武乡县'}],
        [{name:'壶关县',value:30},{name:'武乡县'}],
        [{name:'长子县',value:20},{name:'武乡县'}],
        [{name:'沁县',value:10},{name:'武乡县'}],
        [{name:'沁源县',value:30},{name:'武乡县'}],
        [{name:'潞城市',value:20},{name:'武乡县'}]
    ];
    var QYXDataD = [
        [{name:'郊区',value:95},{name:'沁源县'}],
        [{name:'长治县',value:90},{name:'沁源县'}],
        [{name:'屯留县',value:80},{name:'沁源县'}],
        [{name:'襄垣县',value:70},{name:'沁源县'}],
        [{name:'平顺县',value:60},{name:'沁源县'}],
        [{name:'城区',value:50},{name:'沁源县'}],
        [{name:'黎城县',value:40},{name:'沁源县'}],
        [{name:'壶关县',value:30},{name:'沁源县'}],
        [{name:'长子县',value:20},{name:'沁源县'}],
        [{name:'沁县',value:10},{name:'沁源县'}],
        [{name:'武乡县',value:300},{name:'沁源县'}],
        [{name:'潞城市',value:20},{name:'沁源县'}]
    ];
    var n = 0;
    var OareaData = [['潞城市', LCDataO]];
    var DareaData = [['潞城市', LCDataD]];
    var color = ['#a6c84c', '#ffa022', '#46bee9', '#FFD700', '#FF69B4', '#00CD00', '#32CD32', '#66CD00','#76EE00', '#8A2BE2', '#8B6508', '#9ACD32', '#D15FEE'];
    var Oseries = [];
    var Dseries = [];
    var dataItemO = [];
    var dataItemD = [];
    OAnalysis(OareaData);
    DAnalysis(DareaData);

    // O分析echarts配置
    function  OAnalysis(OareaData) {
        var convertData = function (data) {
            var res = [];
            for (var i = 0; i < data.length; i++) {
                dataItemO = data[i];
                var fromCoord = geoCoordMap[dataItemO[0].name];
                var toCoord = geoCoordMap[dataItemO[1].name];
                if (fromCoord && toCoord) {
                    res.push({
                        fromName: dataItemO[0].name,
                        toName: dataItemO[1].name,
                        coords: [fromCoord, toCoord]
                    });
                }
            }
            return res;
        };
        OareaData.forEach(function (item, i) {
            Oseries.push({
                    name: item[0],
                    type: 'lines',
                    zlevel: 1,
                    effect: {
                        show: true,
                        period: 6,
                        trailLength: 0.7,
                        color: '#fff',
                        symbolSize: 3
                    },
                    lineStyle: {
                        normal: {
                            color: color[n],
                            width: 0,
                            curveness: 0.2
                        }
                    },
                    data: convertData(item[1])
                },
                {
                    name: item[0],
                    type: 'lines',
                    zlevel: 2,
                    symbol: ['none', 'none'],
                    symbolSize: 10,
                    effect: {
                        show: true,
                        period: 6,
                        trailLength: 0,
                        symbol: 'emptyCircle',
                        symbolSize: 1
                    },
                    lineStyle: {
                        normal: {
                            color: color[n],
                            width: 1,
                            opacity: 0.6,
                            curveness: 0.2
                        }
                    },
                    data: convertData(item[1])
                },
                {
                    name: item[0],
                    type: 'effectScatter',
                    coordinateSystem: 'geo',
                    zlevel: 2,
                    rippleEffect: {
                        brushType: 'stroke'
                    },
                    label: {
                        normal: {
                            show: true,
                            position: 'right',
                            formatter: '{b}'
                        }
                    },
                    symbolSize: 5,
                    itemStyle: {
                        normal: {
                            color: color[n]
                        }
                    },
                    data: item[1].map(function (dataItemO) {
                        return {
                            name: dataItemO[1].name,
                            value: geoCoordMap[dataItemO[1].name].concat([dataItemO[1].value])
                        };
                    })
                });
        });
        $.get('../../mapData/map/json/shanxi/长治市.json', function (chinaJson) {

            echarts.registerMap('长治市', chinaJson); // 注册地图

            var mapChartO = echarts.init(document.getElementById('map-wrapO'));

            var option = {
                backgroundColor: '#404a59',  		// 图表背景色
                title : {
                    text: 'O分析',
                    subtext:'',
                    x:'center',
                    textStyle : {
                        color: '#fff'
                    }
                },
                tooltip : {
                    trigger: 'item',
                    formatter: function(params) {
                        var res = params.seriesName + ">" + params.name +"</br>车流量为：" + params.value[2];
                        return res;
                    }
                    //formatter: '{a}>{b}<br/>车流量为：{c}'
                },
                /*legend: {
                        orient: 'vertical',
                        x:'left',
                        data:['潞城市'],
                        selectedMode: 'single',
                        selected:{
                            '上海 Top10' : false,
                            '广州 Top10' : false
                        },
                    textStyle : {
                        color: '#fff'
                    }
                },*/
                toolbox: {
                    show : true,
                    orient : 'vertical',
                    x: 'right',
                    y: 'center',
                    feature : {
                        mark : {show: true},
                        dataView : {show: true, readOnly: false},
                        restore : {show: true},
                        saveAsImage : {show: true}
                    }
                },
                dataRange: {
                    min : 0,
                    max : 1000,
                    calculable : true,
                    color: ['#ff3333', 'orange', 'yellow','lime','aqua'],
                    textStyle:{
                        color:'#fff'
                    }
                },
                geo: {
                    map: '长治市',
                    label: {
                        emphasis: {
                            show: false
                        }
                    },
                    roam: true,
                    itemStyle: {					// 定义样式
                        normal: {					// 普通状态下的样式
                            areaColor: '#323c48',
                            borderColor: '#404a59'
                        },
                        emphasis: {				// 高亮状态下的样式
                            areaColor: '#2a333d'
                        }
                    }
                },
                series: Oseries
            }

            mapChartO.setOption(option);
            mapChartO.on('click', function(params){
                if(params.name == "平顺县"){
                    n ++;
                    Oseries = [];
                    Dseries = [];
                    OareaData = [['平顺县', PSXDataO]];
                    DareaData = [['平顺县', PSXDataD]];
                    OAnalysis(OareaData);
                    DAnalysis(DareaData);
                }
                if(params.name == "潞城市"){
                    n ++;
                    Oseries = [];
                    Dseries = [];
                    OareaData = [['潞城市', LCDataO]];
                    DareaData = [['潞城市', LCDataD]];
                    OAnalysis(OareaData);
                    DAnalysis(DareaData);
                }
                if(params.name == "郊区"){
                    n ++;
                    Oseries = [];
                    Dseries = [];
                    OareaData = [['郊区', JQDataO]];
                    DareaData = [['郊区', JQDataD]];
                    OAnalysis(OareaData);
                    DAnalysis(DareaData);
                }
                if(params.name == "长治县"){
                    n ++;
                    Oseries = [];
                    Dseries = [];
                    OareaData = [['长治县', CZXDataO]];
                    DareaData = [['长治县', CZXDataD]];
                    OAnalysis(OareaData);
                    DAnalysis(DareaData);
                }
                if(params.name == "屯留县"){
                    n ++;
                    Oseries = [];
                    Dseries = [];
                    OareaData = [['屯留县', TLXDataO]];
                    DareaData = [['屯留县', TLXDataD]];
                    OAnalysis(OareaData);
                    DAnalysis(DareaData);
                }
                if(params.name == "襄垣县"){
                    n ++;
                    Oseries = [];
                    Dseries = [];
                    OareaData = [['襄垣县', XHXDataO]];
                    DareaData = [['襄垣县', XHXDataD]];
                    OAnalysis(OareaData);
                    DAnalysis(DareaData);
                }
                if(params.name == "城区"){
                    n ++;
                    Oseries = [];
                    Dseries = [];
                    OareaData = [['城区', CQDataO]];
                    DareaData = [['城区', CQDataD]];
                    OAnalysis(OareaData);
                    DAnalysis(DareaData);
                }
                if(params.name == "黎城县"){
                    n ++;
                    Oseries = [];
                    Dseries = [];
                    OareaData = [['黎城县', LCXDataO]];
                    DareaData = [['黎城县', LCXDataD]];
                    OAnalysis(OareaData);
                    DAnalysis(DareaData);
                }
                if(params.name == "壶关县"){
                    n ++;
                    Oseries = [];
                    Dseries = [];
                    OareaData = [['壶关县', YGXDataO]];
                    DareaData = [['壶关县', YGXDataD]];
                    OAnalysis(OareaData);
                    DAnalysis(DareaData);
                }
                if(params.name == "长子县"){
                    n ++;
                    Oseries = [];
                    Dseries = [];
                    OareaData = [['长子县', ZZXDataO]];
                    DareaData = [['长子县', ZZXDataD]];
                    OAnalysis(OareaData);
                    DAnalysis(DareaData);
                }
                if(params.name == "沁县"){
                    n ++;
                    Oseries = [];
                    Dseries = [];
                    OareaData = [['沁县', QXDataO]];
                    DareaData = [['沁县', QXDataD]];
                    OAnalysis(OareaData);
                    DAnalysis(DareaData);
                }
                if(params.name == "武乡县"){
                    n ++;
                    Oseries = [];
                    Dseries = [];
                    OareaData = [['武乡县', WXXDataO]];
                    DareaData = [['武乡县', WXXDataD]];
                    OAnalysis(OareaData);
                    DAnalysis(DareaData);
                }
                if(params.name == "沁源县"){
                    n ++;
                    Oseries = [];
                    Dseries = [];
                    OareaData = [['沁源县', QYXDataO]];
                    DareaData = [['沁源县', QYXDataD]];
                    OAnalysis(OareaData);
                    DAnalysis(DareaData);
                }
            });//点击事件，此事件还可以用到柱状图等其他地图
        });
    }
    // D分析echarts配置
    function  DAnalysis(DareaData) {
        var convertData = function (data) {
            var res = [];
            for (var i = 0; i < data.length; i++) {
                dataItemD = data[i];
                var fromCoord = geoCoordMap[dataItemD[0].name];
                var toCoord = geoCoordMap[dataItemD[1].name];
                if (fromCoord && toCoord) {
                    res.push({
                        fromName: dataItemD[0].name,
                        toName: dataItemD[1].name,
                        coords: [fromCoord, toCoord]
                    });
                }
            }
            return res;
        };
        DareaData.forEach(function (item, i) {
            Dseries.push({
                    name: item[0],
                    type: 'lines',
                    zlevel: 1,
                    effect: {
                        show: true,
                        period: 6,
                        trailLength: 0.7,
                        color: '#fff',
                        symbolSize: 3
                    },
                    lineStyle: {
                        normal: {
                            color: color[n],
                            width: 0,
                            curveness: 0.2
                        }
                    },
                    data: convertData(item[1])
                },
                {
                    name: item[0],
                    type: 'lines',
                    zlevel: 2,
                    symbol: ['none', 'none'],
                    symbolSize: 10,
                    effect: {
                        show: true,
                        period: 6,
                        trailLength: 0,
                        symbol: 'emptyCircle',
                        symbolSize: 1
                    },
                    lineStyle: {
                        normal: {
                            color: color[n],
                            width: 1,
                            opacity: 0.6,
                            curveness: 0.2
                        }
                    },
                    data: convertData(item[1])
                },
                {
                    name: item[0],
                    type: 'effectScatter',
                    coordinateSystem: 'geo',
                    zlevel: 2,
                    rippleEffect: {
                        brushType: 'stroke'
                    },
                    label: {
                        normal: {
                            show: true,
                            position: 'right',
                            formatter: '{b}'
                        }
                    },
                    symbolSize: 5,
                    itemStyle: {
                        normal: {
                            color: color[n]
                        }
                    },
                    data: item[1].map(function (dataItemD) {
                        return {
                            name: dataItemD[0].name,
                            value: geoCoordMap[dataItemD[0].name].concat([dataItemD[0].value])
                        };
                    })
                });
        });
        $.get('../../mapData/map/json/shanxi/长治市.json', function (chinaJson) {

            echarts.registerMap('长治市', chinaJson); // 注册地图

            var mapChartD = echarts.init(document.getElementById('map-wrapD'));

            var option = {
                backgroundColor: '#404a59',  		// 图表背景色
                title : {
                    text: 'D分析',
                    subtext:'',
                    x:'center',
                    textStyle : {
                        color: '#fff'
                    }
                },
                tooltip : {
                    trigger: 'item',
                    formatter: function(params) {
                        var res = params.seriesName + ">" + params.name +"</br>车流量为：" + params.value[2];
                        return res;
                    }
                    //formatter: '{a}>{b}<br/>车流量为：{c}'
                },
                /*legend: {
                        orient: 'vertical',
                        x:'left',
                        data:['潞城市'],
                        selectedMode: 'single',
                        selected:{
                            '上海 Top10' : false,
                            '广州 Top10' : false
                        },
                    textStyle : {
                        color: '#fff'
                    }
                },*/
                toolbox: {
                    show : true,
                    orient : 'vertical',
                    x: 'right',
                    y: 'center',
                    feature : {
                        mark : {show: true},
                        dataView : {show: true, readOnly: false},
                        restore : {show: true},
                        saveAsImage : {show: true}
                    }
                },
                dataRange: {
                    min : 0,
                    max : 1000,
                    calculable : true,
                    color: ['#ff3333', 'orange', 'yellow','lime','aqua'],
                    textStyle:{
                        color:'#fff'
                    }
                },
                geo: {
                    map: '长治市',
                    label: {
                        emphasis: {
                            show: false
                        }
                    },
                    roam: true,
                    itemStyle: {					// 定义样式
                        normal: {					// 普通状态下的样式
                            areaColor: '#323c48',
                            borderColor: '#404a59'
                        },
                        emphasis: {				// 高亮状态下的样式
                            areaColor: '#2a333d'
                        }
                    }
                },
                series: Dseries
            }

            mapChartD.setOption(option);
            mapChartD.on('click', function(params){
                if(params.name == "平顺县"){
                    n ++;
                    Oseries = [];
                    Dseries = [];
                    OareaData = [['平顺县', PSXDataO]];
                    DareaData = [['平顺县', PSXDataD]];
                    OAnalysis(OareaData);
                    DAnalysis(DareaData);
                }
                if(params.name == "潞城市"){
                    n ++;
                    Oseries = [];
                    Dseries = [];
                    OareaData = [['潞城市', LCDataO]];
                    DareaData = [['潞城市', LCDataD]];
                    OAnalysis(OareaData);
                    DAnalysis(DareaData);
                }
                if(params.name == "郊区"){
                    n ++;
                    Oseries = [];
                    Dseries = [];
                    OareaData = [['郊区', JQDataO]];
                    DareaData = [['郊区', JQDataD]];
                    OAnalysis(OareaData);
                    DAnalysis(DareaData);
                }
                if(params.name == "长治县"){
                    n ++;
                    Oseries = [];
                    Dseries = [];
                    OareaData = [['长治县', CZXDataO]];
                    DareaData = [['长治县', CZXDataD]];
                    OAnalysis(OareaData);
                    DAnalysis(DareaData);
                }
                if(params.name == "屯留县"){
                    n ++;
                    Oseries = [];
                    Dseries = [];
                    OareaData = [['屯留县', TLXDataO]];
                    DareaData = [['屯留县', TLXDataD]];
                    OAnalysis(OareaData);
                    DAnalysis(DareaData);
                }
                if(params.name == "襄垣县"){
                    n ++;
                    Oseries = [];
                    Dseries = [];
                    OareaData = [['襄垣县', XHXDataO]];
                    DareaData = [['襄垣县', XHXDataD]];
                    OAnalysis(OareaData);
                    DAnalysis(DareaData);
                }
                if(params.name == "城区"){
                    n ++;
                    Oseries = [];
                    Dseries = [];
                    OareaData = [['城区', CQDataO]];
                    DareaData = [['城区', CQDataD]];
                    OAnalysis(OareaData);
                    DAnalysis(DareaData);
                }
                if(params.name == "黎城县"){
                    n ++;
                    Oseries = [];
                    Dseries = [];
                    OareaData = [['黎城县', LCXDataO]];
                    DareaData = [['黎城县', LCXDataD]];
                    OAnalysis(OareaData);
                    DAnalysis(DareaData);
                }
                if(params.name == "壶关县"){
                    n ++;
                    Oseries = [];
                    Dseries = [];
                    OareaData = [['壶关县', YGXDataO]];
                    DareaData = [['壶关县', YGXDataD]];
                    OAnalysis(OareaData);
                    DAnalysis(DareaData);
                }
                if(params.name == "长子县"){
                    n ++;
                    Oseries = [];
                    Dseries = [];
                    OareaData = [['长子县', ZZXDataO]];
                    DareaData = [['长子县', ZZXDataD]];
                    OAnalysis(OareaData);
                    DAnalysis(DareaData);
                }
                if(params.name == "沁县"){
                    n ++;
                    Oseries = [];
                    Dseries = [];
                    OareaData = [['沁县', QXDataO]];
                    DareaData = [['沁县', QXDataD]];
                    OAnalysis(OareaData);
                    DAnalysis(DareaData);
                }
                if(params.name == "武乡县"){
                    n ++;
                    Oseries = [];
                    Dseries = [];
                    OareaData = [['武乡县', WXXDataO]];
                    DareaData = [['武乡县', WXXDataD]];
                    OAnalysis(OareaData);
                    DAnalysis(DareaData);
                }
                if(params.name == "沁源县"){
                    n ++;
                    Oseries = [];
                    Dseries = [];
                    OareaData = [['沁源县', QYXDataO]];
                    DareaData = [['沁源县', QYXDataD]];
                    OAnalysis(OareaData);
                    DAnalysis(DareaData);
                }
            });//点击事件，此事件还可以用到柱状图等其他地图
        });
    }
</script>
</html>